﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;

namespace LogicUniversity.clerks
{
    public partial class UpdateDepartment : System.Web.UI.Page
    {
        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //(Session["Role"]
            if (Session["Role"] as string != "Clerk")
            {
                Response.Redirect("~/Login.aspx");
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                DepartmentMaintain dm = new DepartmentMaintain();
                List<Department> ld = new List<Department>();
                txt_deptCode.Enabled = false;
                txt_deptCode.Text = Session["Dept_Code"].ToString();
                txt_deptName.Text = Session["Dept_Name"].ToString();
                txt_contact_Name.Text = Session["Contact_Name"].ToString();
                txt_tel.Text = Session["Tel_No"].ToString();
                txt_fax.Text = Session["Fax_No"].ToString();

                txt_headName.Text = Session["Head_Name"].ToString();
                txt_collectionPoint.Text = Session["Collection_Point"].ToString();
                
                txt_repName.Text = Session["Rep_Name"].ToString();
                Session.Remove("Dept_Code");
                Session.Remove("Dept_Name");
                Session.Remove("Contact_Name");
                Session.Remove("Tel_No");
                Session.Remove("Fax_No");

                Session.Remove("Head_Name");
                Session.Remove("Collection_Point");
                
                Session.Remove("Rep_Name");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DepartmentMaintain dm = new DepartmentMaintain();
            dm.updateDepartment(txt_deptCode.Text, txt_deptName.Text, txt_contact_Name.Text, txt_tel.Text, txt_fax.Text, txt_headName.Text, txt_collectionPoint.Text, txt_repName.Text);
            Response.Redirect("MaintainDepartment.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("MaintainDepartment.aspx");
        }
    }
}